#include "ConfigManager.h"

ConfigManager g_pConfigManager;

char IniPath[512];

void ConfigManager::UpdateFeatureString()
{
	strcpy(ActiveFeatureString, "Active Features:\n \n");
	if (Aimbot)
	{
		if (SilentAim)
		{
			strcat(ActiveFeatureString, "Aimbot (Silent)\n");
		}
		else
		{
			strcat(ActiveFeatureString, "Aimbot\n");
		}
	}
	if (NoSpread)
	{
		strcat(ActiveFeatureString, "NoSpread\n");
	}
	if (NoRecoil)
	{
		strcat(ActiveFeatureString, "NoRecoil\n");
	}
	if (Trigger)
	{
		if (TriggerHeadshotOnly)
		{
			strcat(ActiveFeatureString, "Trigger (HS Only)\n");
		}
		else
		{
			strcat(ActiveFeatureString, "Trigger\n");
		}
	}
	if (Esp)
	{
		strcat(ActiveFeatureString, "Esp\n");
	}
	if (NoSky)
	{
		strcat(ActiveFeatureString, "NoSky\n");
	}
	if (NoFlash)
	{
		strcat(ActiveFeatureString, "NoFlash\n");
	}
	if (NoSmoke)
	{
		strcat(ActiveFeatureString, "NoSmoke\n");
	}
	if (Asus)
	{
		strcat(ActiveFeatureString, "Asus\n");
	}
	if (AutoPistol)
	{
		strcat(ActiveFeatureString, "AutoPistol\n");
	}
	if (Crosshair)
	{
		strcat(ActiveFeatureString, "Crosshair\n");
	}
	if (Bhop)
	{
		strcat(ActiveFeatureString, "Bunnyhop\n");
	}
	if (RadarHack)
	{
		strcat(ActiveFeatureString, "RadarHack\n");
	}
}

void ConfigManager::LoadSection( char* Section )
{
	SD_Tools::AbstractIni::LoadBool(IniPath, Section, "Aimbot", &Aimbot);
	SD_Tools::AbstractIni::LoadBool(IniPath, Section, "SilentAim", &SilentAim);
	SD_Tools::AbstractIni::LoadBool(IniPath, Section, "NoSpread", &NoSpread);
	SD_Tools::AbstractIni::LoadBool(IniPath, Section, "NoRecoil", &NoRecoil);
	SD_Tools::AbstractIni::LoadBool(IniPath, Section, "Trigger", &Trigger);
	SD_Tools::AbstractIni::LoadBool(IniPath, Section, "TriggerHSOnly", &TriggerHeadshotOnly);
	SD_Tools::AbstractIni::LoadBool(IniPath, Section, "Esp", &Esp);
	SD_Tools::AbstractIni::LoadBool(IniPath, Section, "NoSky", &NoSky);
	SD_Tools::AbstractIni::LoadBool(IniPath, Section, "NoFlash", &NoFlash);
	SD_Tools::AbstractIni::LoadBool(IniPath, Section, "NoSmoke", &NoSmoke);
	SD_Tools::AbstractIni::LoadBool(IniPath, Section, "NoHands", &NoHands);
	SD_Tools::AbstractIni::LoadBool(IniPath, Section, "Asus", &Asus);
	SD_Tools::AbstractIni::LoadBool(IniPath, Section, "AutoPistol", &AutoPistol);
	SD_Tools::AbstractIni::LoadBool(IniPath, Section, "Crosshair", &Crosshair);
	SD_Tools::AbstractIni::LoadBool(IniPath, Section, "Bhop", &Bhop);
	SD_Tools::AbstractIni::LoadBool(IniPath, Section, "RadarHack", &RadarHack);
	UpdateFeatureString();
}

void ConfigManager::ExecuteCurrent()
{
	g_pAimbot.Set(Aimbot);
	g_pAimbot.Silent = SilentAim;
	g_pNoSpread.Set(NoSpread);
	g_pNoSpread.SetRecoil(NoRecoil);
	g_pEasyTrigger.Set(Trigger);
	g_pEasyTrigger.SetHeadOnly(TriggerHeadshotOnly);
	g_pESP.Set(Esp);
	g_pCheats.SetNoSky(NoSky);
	g_pNoflash.Set(NoFlash);
	g_pNoSmoke.Set(NoSmoke);
	g_pNoHands.SetActive(NoHands);
	g_pCheats.SetAsus(Asus);
	g_pAutoPistol.Set(AutoPistol);
	g_pCrosshair.Set(Crosshair);
	g_pBHop.Set(Bhop);
	g_pHudRadar.Set(RadarHack);
}

void ConfigManager::Load()
{
	Aimbot = 0;
	SilentAim = 0;
	NoSpread = 0;
	NoRecoil = 0;
	Trigger = 0;
	TriggerHeadshotOnly = 0;
	Esp = 0;
	NoSky = 0;
	NoFlash = 0;
	NoSmoke = 0;
	NoHands = 0;
	Asus = 0;
	AutoPistol = 0;
	Crosshair = 0;
	Bhop = 0;
	RadarHack = 0;
	ActiveFeatureString[0] = '\0';
	wchar_t szPath[512];
	SD_Tools::GetRealDir(g_pInterfaces.hModuleBase, szPath, 512);
	wcscat(szPath, L"\\Config.ini");
	wcstombs(IniPath, szPath, 512);
	LoadSection("Default");
	ExecuteCurrent();
}

void ConfigManager::Execute1()
{
	LoadSection("Insert");
	ExecuteCurrent();
}

void ConfigManager::Execute2()
{
	LoadSection("Delete");
	ExecuteCurrent();
}

void ConfigManager::Execute3()
{
	LoadSection("Home");
	ExecuteCurrent();
}

void ConfigManager::Execute4()
{
	LoadSection("End");
	ExecuteCurrent();
}

void ConfigManager::Execute5()
{
	LoadSection("PgUp");
	ExecuteCurrent();
}

void ConfigManager::Execute6()
{
	LoadSection("PgDn");
	ExecuteCurrent();
}

char* ConfigManager::GetActiveFeatureString()
{
	return ActiveFeatureString;
}

